<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>
        <button id="button0">添加li标签</button>
        <ul id="ulAll">
            <li><a href="#" class="link"> 链接</a></li>
            <li><a href="#" class="link"> 链接2</a></li>
            <li><a href="#" class="link"> 链接3</a></li>

        </ul>
    </div>
    <script>
        //添加
        var button0 = document.getElementById('button0')
        button0.onclick = function () {
            var li = document.createElement('li')
            li.innerHTML = '<a href="#" class = "link"> 链接</a>'
            ulAll.appendChild(li)
        }
        //给父元素绑定事件
        var ulAll = document.getElementById('ulAll')
        ulAll.onclick = function (event) {
            event = event || window.event;
            // target  触发事件的对象
            console.log(event.target);
            if (event.target.className == "link") {
                console.log(1111);
            }




            console.log(111);
            
        }

    </script>
</body>

</html>